package com.sqly.doc.menu.laonian;

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Environment;
import android.support.annotation.IdRes;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RadioGroup;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.loopj.android.http.AsyncHttpResponseHandler;
import com.loopj.android.http.RequestParams;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.sqly.doc.R;
import com.sqly.doc.base.MyBaseActivity;
import com.sqly.doc.menu.camera.CameraChoose;
import com.sqly.doc.menu.gxy.gxy;
import com.sqly.doc.menu.zyy.zyy_jkglfw;
import com.sqly.doc.pojo.JuMin;
import com.sqly.doc.pojo.LaoNianRen;
import com.sqly.doc.pojo.RetMsg;
import com.sqly.doc.user.choose_user;
import com.sqly.doc.util.CreateBitmap;
import com.sqly.doc.util.DateConvert;
import com.sqly.doc.util.HttpUrl;
import com.sqly.doc.util.MyToastUtil;
import com.sqly.doc.util.NetWorkUtils;
import com.sqly.doc.util.SharedPreferencesUtils;
import com.sqly.doc.util.SweetAlertDialogUtil;
import com.sqly.doc.util.Url;
import com.sqly.doc.util.UserClient;
import com.sqly.doc.util.WriteActivity;
import com.sqly.doc.view.CustomDatePicker;
import com.sqly.doc.view.StringUtils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;

import cz.msebera.android.httpclient.Header;

//import cn.pedant.SweetAlert.SweetAlertDialog;


/**
 * Created by Administrator on 2017/11/22 0022.
 */

public class laonianren extends MyBaseActivity {

    private TextView XINGMING;
    private TextView SFRQ;
    TextView ZPG;
    TextView df1,df2,df3,df4,df5;
    LinearLayout back;
    private CustomDatePicker customDatePicker;
    RadioGroup PG1, PG2, PG3, PG4, PG5;
    //标题
    TextView title, uname;
    Context con = laonianren.this;
    LaoNianRen obj;
    String url="";
    TextView xm;
    JuMin j;
    boolean isadd = false;//是否是新添加
    String JKDAH = "";
    ImageView sfysqm, brqm, xcqm;
    String sfysqmpic = "", brqmpic = "",xcqmpic ="";

    ImageView xcpaizhao;
    TextView pz_record_id,jmqm_record_id, ysqm_record_id;
    boolean pzChange = false;

    @Override
    protected void initUI() {
        setContentView(R.layout.laonian);
        //填表日期
        SFRQ = (TextView) findViewById(R.id.SFRQ);
        ZPG = (TextView) findViewById(R.id.ZPG);
        df1= (TextView) findViewById(R.id.df1);
        df2= (TextView) findViewById(R.id.df2);
        df3= (TextView) findViewById(R.id.df3);
        df4= (TextView) findViewById(R.id.df4);
        df5= (TextView) findViewById(R.id.df5);
        XINGMING = (TextView) findViewById(R.id.XINGMING);
        back = (LinearLayout) findViewById(R.id.back);
        title = (TextView) findViewById(R.id.title);
        uname = (TextView) findViewById(R.id.uname);

        //BinderUtil.exeFindById(laonianren.this);
        if (NetWorkUtils.isNetworkConnected(con)) {
            if (getIntent().getStringExtra("type").equals("edit")) {
                obj = (LaoNianRen) getIntent().getExtras().getSerializable("b");
                init(obj);
                if(!StringUtils.isEmpty(obj.getImg())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg(),brqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg()),brqm);
                }
                if(!StringUtils.isEmpty(obj.getImg1())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg1(),sfysqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg1()),sfysqm);
                }
                if(!StringUtils.isEmpty(obj.getImg2())){
                    //ImageLoader.getInstance().displayImage(Url.img_url()+obj.getImg2(),xcqm);
                    ImageLoader.getInstance().displayImage(Url.newStaticurl(SharedPreferencesUtils.getParam(con, "token", "").toString(), "2" ,obj.getImg2()),xcqm);
                }
            }else {
                obj = new LaoNianRen();
                init(obj);
            }

        }
    }

    public void init(final LaoNianRen obj) {
        //运行时生成activity中所有控件的findViewById方法
        //BinderUtil.exeFindById(fjhdycrhsf.this);
        //BinderUtil.initData(laonianren.this, obj);
        if(obj != null && !StringUtils.isEmpty(obj.getSFRQ())){
            SFRQ.setText(DateConvert.dateToString(DateConvert.toDate(obj.getSFRQ(), DateConvert.YMD), DateConvert.YMD)+"");
        }
        SFRQ.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.CHINA);
                String now = sdf.format(new Date());
                customDatePicker = new CustomDatePicker(con, new CustomDatePicker.ResultHandler() {
                    @Override
                    public void handle(String time) { // 回调接口，获得选中的时间
                        SFRQ.setText(time.split(" ")[0]);
                    }
                }, "2010-01-01 00:00", now); // 初始化日期格式请用：yyyy-MM-dd HH:mm，否则不能正常运行
                customDatePicker.showSpecificTime(false); // 不显示时和分
                customDatePicker.setIsLoop(false); // 不允许循环滚动
                customDatePicker.show(now);
            }
        });
        if(obj != null && !StringUtils.isEmpty(obj.getZPG())){
            ZPG.setText(obj.getZPG());
        }
        if(obj != null && !StringUtils.isEmpty(obj.getXINGMING())){
            XINGMING.setText(obj.getXINGMING());
        }
        //医生签名
        sfysqm = (ImageView) findViewById(R.id.sfysqm);
        if (obj != null && !StringUtils.isEmpty(obj.getSfysqm())) {
            sfysqmpic = obj.getSfysqm();
            sfysqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + sfysqmpic + ".jpg"));
        }
        sfysqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "lnrNlpg")
                        .putExtra("imageType", "img1")
                        .putExtra("class", "laonianren.class"), 8);
            }
        });
        //本人签名
        brqm = (ImageView) findViewById(R.id.brqm);
        if (obj != null && !StringUtils.isEmpty(obj.getBrqm())) {
            brqmpic = obj.getBrqm();
            brqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + brqmpic + ".jpg"));
        }
        brqm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                startActivityForResult(new Intent(con, WriteActivity.class)
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "lnrNlpg")
                        .putExtra("imageType", "img")
                        .putExtra("class", "laonianren.class"), 9);
            }
        });
        xcqm = (ImageView) findViewById(R.id.xcqm);
        if (obj != null && !StringUtils.isEmpty(obj.getXcqm())) {
            xcqmpic = obj.getXcqm();
            xcqm.setImageBitmap(BitmapFactory.decodeFile(Environment.getExternalStorageDirectory() + "/" + xcqmpic + ".jpg"));
        }
        xcqm.setOnClickListener(new CustomerListener());
        //现场拍照
        xcpaizhao = (ImageView) findViewById(R.id.xcpaizhao);
        xcpaizhao.setOnClickListener(new CustomerListener());
        //现场拍照照片id
        pz_record_id = (TextView) findViewById(R.id.pz_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg2())) {
            //fjhdycrhsf/D24E75C5BB5E417EBE65494CA09BF399.jpg
            String[] img2Arr =obj.getImg2().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                pz_record_id.setText(img2Arr[1]);
            }
        }
        jmqm_record_id= (TextView) findViewById(R.id.jmqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg())) {
            String[] img2Arr =obj.getImg().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                jmqm_record_id.setText(img2Arr[1]);
            }
        }
        ysqm_record_id= (TextView) findViewById(R.id.ysqm_record_id);
        if(obj != null && !StringUtils.isEmpty(obj.getImg1())) {
            //fjhdycrhsf/D24E75C5BB5E417EBE65494CA09BF399.jpg
            String[] img2Arr =obj.getImg1().split("/");
            if(null !=img2Arr && img2Arr.length>1){
                ysqm_record_id.setText(img2Arr[1]);
            }
        }

        //姓名
        XINGMING.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if (!NetWorkUtils.isNetworkConnected(con)) {
                    MyToastUtil.ShowToast(con, "联网失败！");
                }else {
                    Bundle bundle = getIntent().getExtras();
                    if (null != bundle.getString("type") && "add".equals(bundle.getString("type"))) {
                        startActivityForResult(new Intent(con, choose_user.class).putExtra("cname", "laonianren.class"), 1);
                    }
                }

            }
        });

        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if(pzChange){
                   SweetAlertDialogUtil.WarningDialogHaveCancelAndConfirm(con,"你确认不保存数据更新吗？","现场拍照已经采集，请注意点击“保存”","确定", "返回");
                }else {
                    finish();
                }
            }
        });

        title.setText("老年人生活自理能力评估");
        uname.setText("保存");
        uname.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                //boolean validate = BinderUtil.copyDataToView(laonianren.this, obj);
                String xm = XINGMING.getText().toString();
                String rq = SFRQ.getText().toString();
                String zdf = ZPG.getText().toString();
                if(null == xm || "".equals(xm) || "点我选择".equals(xm)){
                    MyToastUtil.ShowToast(con, "请选择个人信息！");
                }else if(null == rq || "".equals(rq)){
                    MyToastUtil.ShowToast(con, "请选择评估日期！");
                }else if(null == zdf || "".equals(zdf) ){
                    MyToastUtil.ShowToast(con, "请选择评估事项！");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "ysqm", "0").toString()) && ysqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "随访医生签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "jmqm", "0").toString()) && jmqm_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "家属或本人签名不能为空");
                }else if ("1".equals(SharedPreferencesUtils.getParam(con, "xcpz", "0").toString()) && pz_record_id.getText().toString().equals("noid")) {
                    SweetAlertDialogUtil.WarningDialog(con, "提示", "现场拍照不能为空");
                }else if (NetWorkUtils.isNetworkConnected(con)) {  ///网络连接
                    //RequestParams ps = BinderUtil.generateRequestParamsByView(laonianren.this);
                    RequestParams ps = new RequestParams();
                    if (isadd) {
                        ps.add("entity.JKDAH", JKDAH);
                        url = HttpUrl.SaveLnr;
                    } else {
                        ps.add("entity.SFJLH", obj.getSFJLH());
                        ps.add("entity.JKDAH", obj.getJKDAH());
                        url = HttpUrl.EditLnr;
                    }
                    ps.add("entity.XINGMING",obj.getXINGMING());
                    ps.add("entity.PG1", obj.getPG1());
                    ps.add("entity.PG2",obj.getPG2());
                    ps.add("entity.PG3", obj.getPG3());
                    ps.add("entity.PG4", obj.getPG4());
                    ps.add("entity.PG5", obj.getPG5());
                    ps.add("entity.SFRQ", rq);
                    ps.add("entity.CARDNUM", obj.getCARDNUM());
                    ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
                    ps.add("type", "2");

                    ps.add("pz_record_id", pz_record_id.getText().toString());
                    ps.add("jmqm_record_id", jmqm_record_id.getText().toString());
                    ps.add("ysqm_record_id", jmqm_record_id.getText().toString());
                    ps.add("entity.UPDATETIME", obj.getUPDATETIME());
                    //laonianren.super.ImageUploadOperate(sfysqmpic, brqmpic, ps);
                    UserClient.get(url, ps, new AsyncHttpResponseHandler() {
                        @Override
                        public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                            String content = new String(response);
                            RetMsg ret = JSON.parseObject(content, RetMsg.class);
                            if (ret.getCode().equals("200")) {
                                MyToastUtil.ShowToast(con, "成功");
                            }else{
                                MyToastUtil.ShowToast(con, ret.getInfo());
                            }
                            finish();
                        }

                        @Override
                        public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {
                            MyToastUtil.ShowToast(con, "失败");
                        }
                    });
                } else {
                    MyToastUtil.ShowToast(con, "失败");
                }
            }
        });

        initRadioGroup(obj);
    }

    public void initRadioGroup(final LaoNianRen obj) {
        //进餐
        PG1 = (RadioGroup) findViewById(R.id.PG1);
        PG1.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.jc1) {
                    obj.setPG1("0");
                    setDf1(0);
                    getzong();
                }
                if (checkedId == R.id.jc2) {
                    obj.setPG1("3");
                    setDf1(3);
                    getzong();
                }
                if (checkedId == R.id.jc3) {
                    obj.setPG1("5");
                    setDf1(5);
                    getzong();
                }
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getPG1())) {
            switch (Integer.parseInt(obj.getPG1())) {
                case 0:
                    PG1.check(R.id.jc1);
                    break;
                case 3:
                    PG1.check(R.id.jc2);
                    break;
                case 5:
                    PG1.check(R.id.jc3);
                    break;
            }
        }else{
            PG1.check(R.id.jc1);
        }
        //梳洗
        PG2 = (RadioGroup)findViewById(R.id.PG2);
        PG2.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.xs1) {
                    obj.setPG2("0");
                    setDf2(0);
                    getzong();
                }
                if (checkedId == R.id.xs2) {
                    obj.setPG2("1");
                    setDf2(1);
                    getzong();
                }
                if (checkedId == R.id.xs3) {
                    obj.setPG2("3");
                    setDf2(3);
                    getzong();
                }
                if (checkedId == R.id.xs4) {
                    obj.setPG2("7");
                    setDf2(7);
                    getzong();
                }
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getPG2())) {
            switch (Integer.parseInt(obj.getPG2())) {
                case 0:
                    PG2.check(R.id.xs1);break;
                case 1:
                    PG2.check(R.id.xs2);break;
                case 3:
                    PG2.check(R.id.xs3);break;
                case 7:
                    PG2.check(R.id.xs4);break;
            }
        }else{
            PG2.check(R.id.xs1);
        }
        //穿衣
        PG3 = (RadioGroup)findViewById(R.id.PG3);
        PG3.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.cy1) {
                    obj.setPG3("0");
                    setDf3(0);
                    getzong();
                }
                if (checkedId == R.id.cy2) {
                    obj.setPG3("3");
                    setDf3(3);
                    getzong();
                }
                if (checkedId == R.id.cy3) {
                    obj.setPG3("5");
                    setDf3(5);
                    getzong();
                }
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getPG3())) {
            switch (Integer.parseInt(obj.getPG3())) {
                case 0:
                    PG3.check(R.id.cy1);break;
                case 3:
                    PG3.check(R.id.cy2);break;
                case 5:
                    PG3.check(R.id.cy3);break;
            }
        }else{
            PG3.check(R.id.cy1);
        }
        //如厕
        PG4 = (RadioGroup)findViewById(R.id.PG4);
        PG4.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.rc1) {
                    obj.setPG4("0");
                    setDf4(0);
                    getzong();
                }
                if (checkedId == R.id.rc2) {
                    obj.setPG4("1");
                    setDf4(1);
                    getzong();
                }
                if (checkedId == R.id.rc3) {
                    obj.setPG4("5");
                    setDf4(5);
                    getzong();
                }
                if (checkedId == R.id.rc4) {
                    obj.setPG4("10");
                    setDf4(10);
                    getzong();
                }
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getPG4())) {
            switch (Integer.parseInt(obj.getPG4())) {
                case 0:
                    PG4.check(R.id.rc1);break;
                case 1:
                    PG4.check(R.id.rc2);break;
                case 5:
                    PG4.check(R.id.rc3);break;
                case 10:
                    PG4.check(R.id.rc4);break;
            }
        }else{
            PG4.check(R.id.rc1);
        }
        //活动
        PG5 = (RadioGroup)findViewById(R.id.PG5);
        PG5.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {
                if (checkedId == R.id.hd1) {
                    obj.setPG5("0");
                    setDf5(0);
                    getzong();
                }
                if (checkedId == R.id.hd2) {
                    obj.setPG5("1");
                    setDf5(1);
                    getzong();
                }
                if (checkedId == R.id.hd3) {
                    obj.setPG5("5");
                    setDf5(5);
                    getzong();
                }
                if (checkedId == R.id.hd4) {
                    obj.setPG5("10");
                    setDf5(10);
                    getzong();
                }
            }
        });
        if (obj != null && !StringUtils.isEmpty(obj.getPG5())) {
            switch (Integer.parseInt(obj.getPG5())) {
                case 0:
                    PG5.check(R.id.hd1);break;
                case 1:
                    PG5.check(R.id.hd2);break;
                case 5:
                    PG5.check(R.id.hd3);break;
                case 10:
                    PG5.check(R.id.hd4);break;
            }
        }else{
            PG5.check(R.id.hd1);
        }
    }

    private void setDf1(int newDefen) {
        String olddf1 = df1.getText().toString();
        df1.setText(""+newDefen);
    }
    private void setDf2(int newDefen) {
        String olddf2 = df2.getText().toString();
        df2.setText(""+newDefen);
    }
    private void setDf3(int newDefen) {
        String olddf3 = df3.getText().toString();
        df3.setText(""+newDefen);
    }
    private void setDf4(int newDefen) {
        String olddf4 = df4.getText().toString();
        df4.setText(""+newDefen);
    }
    private void setDf5(int newDefen) {
        String olddf5 = df5.getText().toString();
        df5.setText(""+newDefen);
    }


    private void getzong() {
        String olddf1 = df1.getText().toString();
        String olddf2 = df2.getText().toString();
        String olddf3 = df3.getText().toString();
        String olddf4 = df4.getText().toString();
        String olddf5 = df5.getText().toString();

        ZPG.setText(""+(Integer.parseInt(olddf1)+Integer.parseInt(olddf2)+Integer.parseInt(olddf3)+Integer.parseInt(olddf4)+Integer.parseInt(olddf5)));
    }


    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (data == null) {

        } else if (requestCode == 1) {
            j = (JuMin) data.getExtras().getSerializable("j");
            getObject();
        }else if (requestCode == 8) {
            String record_id = (String) data.getExtras().getString("record_id");
            ysqm_record_id.setText(record_id);
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            sfysqm.setImageBitmap(bb);
            sfysqmpic = CreateBitmap.saveMyBitmap(bb);
        }else if (requestCode == 9) {
            String record_id = (String) data.getExtras().getString("record_id");
            jmqm_record_id.setText(record_id);
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            brqm.setImageBitmap(bb);
            brqmpic = CreateBitmap.saveMyBitmap(bb);
        }else if(requestCode == 119){
            String img_record_id = (String) data.getExtras().getString("img_record_id");
            pz_record_id.setText(img_record_id);
            pzChange = true;
            byte[] bis = data.getByteArrayExtra("bitmap");
            Bitmap bmp = BitmapFactory.decodeByteArray(bis, 0, bis.length);
            Bitmap bb = CreateBitmap.zoomImg(bmp, 1, 1);
            xcqm.setImageBitmap(bb);
        }
    }

    public void getObject() {
        RequestParams ps = new RequestParams();
        ps.add("token", SharedPreferencesUtils.getParam(con, "token", "").toString());
        ps.add("type", "2");
        ps.add("CARDNUM", j.getCARDNUM());
        UserClient.get(HttpUrl.GetLnrGrjbxx, ps, new AsyncHttpResponseHandler() {
            @Override
            public void onSuccess(int statusCode, Header[] headers, byte[] response) {
                String content = new String(response);
                RetMsg ret = JSON.parseObject(content, RetMsg.class);
                if (ret.getCode().equals("200")) {
                    JSONObject j = JSON.parseObject(ret.getRd());
                    obj = new LaoNianRen();
                    init(obj);
                    obj.setJKDAH(j.getString("JKDAH"));
                    obj.setXINGMING(j.getString("XINGMING"));
                    obj.setCARDNUM(j.getString("CARDNUM"));
                    JKDAH = j.getString("JKDAH");
                    XINGMING.setText(j.getString("XINGMING"));
                    isadd = true;
                } else {
                    SweetAlertDialogUtil.ErrorDialogNoFinish(con, "错误提示", ret.getInfo(), "确定");
                }
            }
            @Override
            public void onFinish() {
                super.onFinish();
            }

            @Override
            public void onFailure(int statusCode, Header[] headers, byte[] errorResponse, Throwable e) {

                isadd = true;
                obj = new LaoNianRen();
                init(obj);
            }
        });
    }

    class CustomerListener implements View.OnClickListener {
        @Override
        public void onClick(View v) {
            if(obj != null && StringUtils.isEmpty(obj.getJKDAH())) {
                SweetAlertDialogUtil.WarningDialog(con, "提示", "选择居民用户后才能现场拍照");
            }else {
                Intent intent = new Intent(con, CameraChoose.class)
                        .putExtra("type", "edit")
                        .putExtra("cardnum", obj.getCARDNUM())
                        .putExtra("tabId", null==obj.getSFJLH()||"".equals(obj.getSFJLH()) ? "noid" : obj.getSFJLH())
                        .putExtra("tabType", "lnrNlpg")
                        .putExtra("class", "laonianren.class");
                startActivityForResult(intent, 119);
            }
        }
    }
}
